//
//  SYXinDeView.m
//  SanYiTeaching
//
//  Created by 郑浩然 on 2019/4/23.
//  Copyright © 2019年 SanYi. All rights reserved.
//

#import "SYXinDeView.h"
#import "SYCYHeaderView.h"
#import "SYDetailsXinDeView.h"//资源学习心得
#import "SYTingKeJiLuView.h" //听课记录
#import "SYTingKeXinDeView.h" //听课心得
#import "SYZhuZiGaoView.h" //逐字稿
#import "SYGuoKeView.h"//g

@interface SYXinDeView ()

@property (strong, nonatomic) SYBackTopView *backView;//顶部viwe

@property (assign, nonatomic) SYDetailsType type;

@property (strong, nonatomic) SYDetailsXinDeView *xindeView;//资源学习心得

@property (strong, nonatomic) SYTingKeJiLuView *jiluView;//听课记录

@property (strong, nonatomic) SYTingKeXinDeView *tingkeView;//听课心得

@property (strong, nonatomic) SYZhuZiGaoView *zhuzigaoView;//逐字稿

@property (strong, nonatomic) SYGuoKeView *guokeView;//过客

@property (assign, nonatomic) SYXinDeViewType stus;

@end


@implementation SYXinDeView

- (instancetype)initWithFrame:(CGRect)frame detailsType:(SYDetailsType)type xindeViewType:(SYXinDeViewType)stus {
    self = [super initWithFrame:frame];
    if (self) {
        _type = type;
        _stus = stus;
        self.backgroundColor = [UIColor colorWithHexString:@"#EEEEEE"];
        [self initSubView];
    }
    return self;
}

- (void)initSubView {
    [self addSubview:self.backView];
    [self.backView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self);
        make.height.mas_equalTo(50);
    }];
    
    SYCYHeaderView *headerView = [[SYCYHeaderView alloc] init];
    headerView.backgroundColor = [UIColor whiteColor];
    [self addSubview:headerView];
    if (_stus == SYXinDeViewTypeTuDi) {
        headerView.nameView.hidden = YES;
        [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.backView.mas_bottom);
            make.left.equalTo(self.mas_left).offset(14);
            make.right.equalTo(self.mas_right).offset(-14);
            make.height.mas_equalTo(190-30);
        }];
    } else {
        [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.backView.mas_bottom);
            make.left.equalTo(self.mas_left).offset(14);
            make.right.equalTo(self.mas_right).offset(-14);
            make.height.mas_equalTo(190);
        }];
    }
   
    
    if (self.type == SYDetailsTypeZiYuanXind) {//学习心得
        headerView.topView.titleLab.text = @"资源学习心得";
        [self addSubview:self.xindeView];
        [self.xindeView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(headerView.mas_bottom).offset(0);
            make.left.equalTo(self.mas_left).offset(0);
            make.right.equalTo(self.mas_right).offset(0);
            make.bottom.equalTo(self);
        }];
    } else if (self.type == SYDetailsTypeXinDe) {//听课心得
        headerView.topView.titleLab.text = @"听课记录";
        self.backView.titleLab.text = @"成员听课记录";
        [self addSubview:self.jiluView];
        [self.jiluView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(headerView.mas_bottom).offset(0);
            make.left.equalTo(self.mas_left).offset(0);
            make.right.equalTo(self.mas_right).offset(0);
            make.bottom.equalTo(self);
        }];
        
    } else if (self.type == SYDetailsTypeJiLu) {//听课记录
        headerView.topView.titleLab.text = @"听课心得";
        self.backView.titleLab.text = @"成员听课心得";
        [self addSubview:self.tingkeView];
        [self.tingkeView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(headerView.mas_bottom).offset(0);
            make.left.equalTo(self.mas_left).offset(0);
            make.right.equalTo(self.mas_right).offset(0);
            make.bottom.equalTo(self);
        }];
    } else if (self.type == SYDetailsTypeZhuZiGao) {//成员逐字稿
        headerView.topView.titleLab.text = @"逐字稿";
        self.backView.titleLab.text = @"成员逐字稿";
        [self addSubview:self.zhuzigaoView];
        [self.zhuzigaoView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(headerView.mas_bottom).offset(0);
            make.left.equalTo(self.mas_left).offset(0);
            make.right.equalTo(self.mas_right).offset(0);
            make.bottom.equalTo(self);
        }];
        
    } else if (self.type == SYDetailsTypeGuoKe) {//过客
        headerView.topView.titleLab.text = @"成员过客";
        self.backView.titleLab.text = @"过客信息";
        [self addSubview:self.guokeView];
        [self.guokeView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(headerView.mas_bottom).offset(0);
            make.left.equalTo(self.mas_left).offset(0);
            make.right.equalTo(self.mas_right).offset(0);
            make.bottom.equalTo(self);
        }];
        
        
    }
}


#pragma mark - set
//头部
- (SYBackTopView *)backView {
    if (!_backView) {
        _backView = [[SYBackTopView alloc] initWithTitleName:@"资源学习心得" baseView:self];
    }
    return _backView;
}
//心得
- (SYDetailsXinDeView *)xindeView {
    if (!_xindeView) {
        _xindeView = [[SYDetailsXinDeView alloc] init];
    }
    return _xindeView;
}
//听课记录
- (SYTingKeJiLuView *)jiluView {
    if (!_jiluView) {
        _jiluView = [[SYTingKeJiLuView alloc] init];
    }
    return _jiluView;
}
//听课心得
- (SYTingKeXinDeView *)tingkeView {
    if (!_tingkeView) {
        _tingkeView = [[SYTingKeXinDeView alloc] init];
    }
    return _tingkeView;
}
//逐字稿
- (SYZhuZiGaoView *)zhuzigaoView {
    if (!_zhuzigaoView) {
        _zhuzigaoView = [[SYZhuZiGaoView alloc] init];
    }
    return _zhuzigaoView;
}
//过客
- (SYGuoKeView *)guokeView {
    if (!_guokeView) {
        _guokeView = [[SYGuoKeView alloc] init];
    }
    return _guokeView;
}


@end




















